package com.br.cashflowdao.hibernate.dao.entities;

import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Marcel Sena <marcel.sena at marcel.sena@gmail.com>
 * @version 1.0
 * @since 05/01/2009
 */
@Entity
@Table(name="TRANSFER_TRANSACTION"
    ,catalog="cashflow"
)
public class TransferTransaction  implements java.io.Serializable, IEntity {

     private Long id;
     private Date createDate;
     private Date updateDate;
     private DebitTransaction debitTransaction;
     private CreditTransaction creditTransaction;

    public TransferTransaction() {}

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="TRANSFER_ID", unique=true, nullable=false)
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long transferId) {
        this.id = transferId;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="CREATE_DATE", nullable=false, length=10)
    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="UPDATE_DATE", nullable=false, length=10)
    public Date getUpdateDate() {
        return this.updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    @OneToOne(optional=false, cascade=CascadeType.ALL)
    @JoinColumn(name="DEBIT_TRANSACTION_ID", unique=true, nullable=false, updatable=false)
    public DebitTransaction getDebitTransaction() {
        return this.debitTransaction;
    }

    public void setDebitTransaction(DebitTransaction debitTransaction) {
        this.debitTransaction = debitTransaction;
    }

    @OneToOne(optional=false, cascade=CascadeType.ALL)
    @JoinColumn(name="CREDIT_TRANSACTION_ID", unique=true, nullable=false, updatable=false)
    public CreditTransaction getCreditTransaction() {
        return this.creditTransaction;
    }
    
    public void setCreditTransaction(CreditTransaction creditTransaction) {
        this.creditTransaction = creditTransaction;
    }

}